<?php

namespace app\modules\frontend\controllers;

use Yii;

use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use app\models\Park;
use app\models\Product;
use yii\data\ActiveDataProvider;

class ProductController extends Controller{

    public function actionIndex()  //在这个方法中  左侧显示已经查询到的园区
   {//查询到所有的园区
      $this->layout='product';
       $parks=Park::find()->all();
      return $this->render('index',['parks'=>$parks]);  //传递到该视图中
   }

    public function actionDetail($id=2)  //点击相应的园区 可以看到园区内的产品
    {
        $this->layout = 'product';

        $sql="select * from shbb_product where park_id=$id";

        $products=Product::findBySql($sql)->all();   //根据id在园区产品表中查询

        return $this->render('detail',['products'=>$products]);

    }

}